<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>登录</title>
    <meta name="keywords" content="(www.eblog.site),博文分享，技术博文，影音推荐，美食分享，生活技巧，笑话大全"/>
	<meta name="description" content="eBlog分享网(www.eblog.site)为广大朋友们提供有技术的博文，最新最热门的电影音乐。看到就流口水的美食，各种生活技巧，笑喘不过气的笑话！ "/>
    <link rel="shortcut icon" href="assets/favicon.ico"> 
    <link href="assets/manager/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="assets/manager/css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="assets/manager/css/animate.css" rel="stylesheet">
    <link href="assets/manager/css/style.css?v=4.1.0" rel="stylesheet">
    <!--[if lt IE 9]>
    <meta http-equiv="refresh" content="0;ie.html" />
    <![endif]-->
    <script>if(window.top !== window.self){ window.top.location = window.location;}</script>
</head>
<body class="gray-bg">
    <div class="middle-box text-center loginscreen  animated fadeInDown">
        <div>
            <div>
                <h1 class="logo-name">E</h1>
            </div>
            <h3>欢迎使用 eBlog</h3>

                <div class="form-group">
                    <input type="text" id="userName" class="form-control" placeholder="用户名" required="">
                </div>
                <div class="form-group">
                    <input type="password" id="password" class="form-control" placeholder="密码" required="">
                </div>
                <div class="form-group loginyzmBox">
                    <input type="text" id="captcha" class="form-control" placeholder="验证码" required="">
                    <img class="loginyzm" src="kaptcha.jpg" alt="换一张" onclick="this.src='kaptcha.jpg?d='+new Date().getTime()">
                </div>
                <button type="submit" id="submit" class="btn btn-primary block full-width m-b">登 录</button>
                <p class="text-muted text-center"> 
                <a href="login.html#"><small>忘记密码了？</small></a> | 
                <a href="register">注册一个新账号</a> | 
                <a href="/">返回首页</a>
                </p>
        </div>
    </div>
    <!-- 全局js -->
    <script src="assets/manager/js/jquery.min.js?v=2.1.4"></script>
    <script src="assets/manager/js/bootstrap.min.js?v=3.3.6"></script>
    <script>
    $(document).ready(function(){
    	$(document).keydown(function(event){  
    	  if(event.keyCode == 13 || event.keyCode == 108){  
    		  login();  
    	  } 
    	}); 
    	
    	$("#submit").click(function(){
    		if($("#captcha").val() == ""){
    			alert("请输入验证码。");
    		}else{
    			login();
    		}
    	});
    	function login(){
    		$.ajax({
    			type:"post",
    			url:"login.do",
    			dataType:"json",
    			data:{
    				"userName":$("#userName").val(),
    				"password":$("#password").val(),
    				"captcha":$("#captcha").val()
    			},
    			success:function(data){
    				if(data.res){
    					window.location.href = "/";
    				}else{
    					alert(data.msg);
    					if(data.msg.indexOf("验证码错误！") != -1){
    						$(".loginyzmBox img").trigger("click");
    					}
    				}
    			}
    		})
    	};
    });
    </script>
</body>
</html>